home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
idioms.lha
/
idioms
/
3-14.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
786b
|
31 lines
/* Copyright (c) 1992 by AT&T Bell Laboratories. */
/* Advanced C++ Programming Styles and Idioms */
/* James O. Coplien */
/* All rights reserved. */
#include <stdlib.h>
#include <string.h>
// a dumb string (not a concrete data type)
// to demonstrate new/delete
class String {
public:
String() { rep = new char[1]; *rep = '\e0'; }
String(const char *s) {
rep = new char[::strlen(s)+1];
::strcpy(rep,s);
}
~String() { delete[] rep; }
void* operator new(size_t);
void operator delete(void*);
// . . . . // other interesting operations
private:
static String *newlist;
union {
String *freepointer;
char *rep;
};
int len;
};